/* Copyright (c) 2008 Google Inc.
*  Copyright (c) 2009 Pierre Henri Kuate.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

namespace org.opensocial.client
{
    public class OpenSocialRequestParameter
    {
        private readonly System.Collections.Generic.List<string> _values = new System.Collections.Generic.List<string>();

        public OpenSocialRequestParameter(params string[] values)
        {
            addValues(values);
        }

        public void addValues(params string[] values)
        {
            _values.AddRange(values);
        }

        public void addValue(string value)
        {
            _values.Add(value);
        }

        public System.Collections.Generic.List<string> getValues()
        {
            return _values;
        }

        public string getValuesString()
        {
            var list = new System.Text.StringBuilder();

            for (int i = 0; i < _values.Count; i++)
            {
                if (i != 0)
                    list.Append(",");

                list.Append(_values[i]);
            }

            return list.ToString();
        }

        /// <summary>
        /// Returns true if the number of stored values is greater than one, false otherwise.
        /// </summary>
        public bool isMultivalued()
        {
            return _values.Count > 1;
        }
    }
}